import Vditor from "vditor";

const cacheId = "markdowCache";

export default class MdEditor {
  constructor() {}

  init(id) {
    this.vditor = new Vditor(id, {
      height: "88vh",
      cache: {
        id: cacheId,
      },
      after() {
        this.vditor.focus();
      },
    });
  }

  getValue() {
    return this.vditor.getValue();
  }
  setValue(val) {
    this.vditor.setValue(val);
  }
  getCacheValue() {
    localStorage.getItem(cacheId);
  }
  clearCache() {
    this.vditor.clearCache();
  }
}
